<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<script type="text/javascript">
	$(function() {
		$('#setPeopleid').tree({
			checkbox : true,
			url : 'userController.do?setAuthority&ids=${ids}',
			onLoadSuccess : function(node) {
				//expandAll();
			}
		});
	});
	
	function mysubmit() {
		var wbid = $("#wbid").val();
		var s = GetNode();
		doSubmit("documentPeopleController.do?updateAuthority&ids="+s+ "&wbid=" + wbid);
	}
	
	function GetNode() {
		var node = $('#setPeopleid').tree('getChecked');
		var cnodes = '';
		var pnodes = '';
		var prevNode = ''; //保存上一步所选父节点
		for ( var i = 0; i < node.length; i++) {
			if ($('#setPeopleid').tree('isLeaf', node[i].target)) {
				cnodes += node[i].id + ',';
				var pnode = $('#setPeopleid').tree('getParent', node[i].target); //获取当前节点的父节点
				if (prevNode != pnode.id) //保证当前父节点与上一次父节点不同
				{
					pnodes += pnode.id + ',';
					prevNode = pnode.id; //保存当前节点
				}
			}
		}
		cnodes = cnodes.substring(0, cnodes.length - 1);
		pnodes = pnodes.substring(0, pnodes.length - 1);
		return cnodes ;
	};
	
	function GetName() {
		var node = $('#setPeopleid').tree('getChecked');
		var cnodes = '';
		var pnodes = '';
		var prevNode = ''; //保存上一步所选父节点
		for ( var i = 0; i < node.length; i++) {
			if ($('#setPeopleid').tree('isLeaf', node[i].target)) {
				cnodes += node[i].text + ',';
				var pnode = $('#setPeopleid').tree('getParent', node[i].target); //获取当前节点的父节点
				if (prevNode != pnode.id) //保证当前父节点与上一次父节点不同
				{
					pnodes += pnode.text + ',';
					prevNode = pnode.id; //保存当前节点
				}
			}
		}
		cnodes = cnodes.substring(0, cnodes.length - 1);
		pnodes = pnodes.substring(0, pnodes.length - 1);
		return cnodes;
	};

	function expandAll() {
		var node = $('#setPeopleid').tree('getSelected');
		if (node) {
			$('#setPeopleid').tree('expandAll', node.target);
		} else {
			$('#setPeopleid').tree('expandAll');
		}
	}
	//update-begin--Author:anchao  Date:20130324 for：角色编辑全选、取消菜单
	function selecrAll() {
		var node = $('#setPeopleid').tree('getRoots');
		for ( var i = 0; i < node.length; i++) {
			var childrenNode = $('#setPeopleid').tree('getChildren',node[i].target);
			for ( var j = 0; j < childrenNode.length; j++) {
				$('#setPeopleid').tree("check", childrenNode[j].target);
			}
		}
	}
	function reset() {
		$('#setPeopleid').tree('reload');
	}

	$('#selecrAllBtn').linkbutton({});
	$('#resetBtn').linkbutton({});

	//update-end--Author:zhangdaihao  Date:20130205 for：角色编辑全选、取消菜单
</script>
<div class="easyui-layout" fit="true">
	<div region="center" style="padding: 1px;">
		<div class="easyui-panel" style="padding: 1px;" fit="true"
			border="false" id="peopleListPanel">
			
			<a id="selecrAllBtn" class="easyui-linkbutton" onclick="selecrAll();">全选</a> 
			<a id="resetBtn" class="easyui-linkbutton" onclick="reset();">重置</a>
			
			<!-- update-end--Author:zhangdaihao  Date:20130205 for：角色编辑全选、取消菜单 -->
			<ul id="setPeopleid"></ul>
		</div>
	</div>
</div>
